package com.coffeeloversupportlibrary.coffeelover.domain.article.cotegory;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.coffeeloversupportlibrary.R;
import com.coffeeloversupportlibrary.databinding.GameQuestionFragmentBinding;
import com.scwang.smart.refresh.footer.BallPulseFooter;
import com.scwang.smart.refresh.header.BezierRadarHeader;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnLoadMoreListener;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;

import java.io.IOException;
import java.util.List;
import java.util.Random;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

/**
 * @author puyv
 * @createTime 2021/11/14 21:47
 * @projectName CoffeeLoverSupportLibrary
 * @className GameFragment.java
 * @description TODO
 */
public class GameFragment extends Fragment implements View.OnClickListener {
    private GameQuestionFragmentBinding gameQuestionFragmentBinding;


    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        //todo bugs container 空应用
        //todo 原始代码  .from(container.getContext())---container == null---ViewGroup.getContext()
        //this.getContext()  修改代码   bug点四--对比其他   containter --- 当前 Fragment 视图的容器（ViewGroup  可能为空（Viewpage 而viewpage 又是 recyclerView 的一个子项目 收到RecyclerView 回收机制的作用  某些时机可能会被回收 可能会出现
        // 空值  从而产生隐藏的bug---特定情况下运行时异常   程序闪退））

        //todo : categoryItemFragmnetBinding= DataBindingUtil.inflate(inflater, R.layout.category_item_fragmnet,container,false);
        //        initView();
        //        return categoryItemFragmnetBinding.getRoot();     其他文章类别页的方案  结合分析  &&& container.getContext()--引发了不可预知的运行时异常
        View view = LayoutInflater.from(this.getContext()).inflate(R.layout.game_question_fragment,container,false);
        /**
        * @date 2021/11/15 8:01
        * @params [inflater, container, savedInstanceState]
        * @return android.view.View
        * @description TODO  bug信息：java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.view.ViewGroup.getContext()' on a null object reference
         * 产生操作：切换主页面的 Fragment  Fragment 对象的回收？？？
        */
        gameQuestionFragmentBinding= DataBindingUtil.bind(view);
        init();
        return view;
    }
    private void init(){
        gameQuestionFragmentBinding.questionEnter.setOnClickListener(this);
        gameQuestionFragmentBinding.activityEnter.setOnClickListener(this);
        gameQuestionFragmentBinding.gameEnter.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if(v==gameQuestionFragmentBinding.activityEnter){
            Toast.makeText(getContext(),"别点了，还没做呢",Toast.LENGTH_LONG).show();

        }else if(v==gameQuestionFragmentBinding.questionEnter){
            Toast.makeText(getContext(),"还点",Toast.LENGTH_LONG).show();

        }else if(v==gameQuestionFragmentBinding.gameEnter){

        }
    }


}
